//
//  PregnantWomanController.m
//  HarmonizePub
//
//  Created by rzhy on 2016/10/9.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "PregnantWomanController.h"
#import "Config.h"

@interface PregnantWomanController ()

@property (weak, nonatomic) IBOutlet UILabel *resultText;
@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;
@property (weak, nonatomic) IBOutlet UIButton *resultButton;

@end

@implementation PregnantWomanController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"预产期自测";
    self.resultButton.layer.cornerRadius = 5.0f;
    self.resultButton.layer.masksToBounds = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 查看结果
- (IBAction)seeResult:(UIButton *)sender {
    NSDate *date = self.datePicker.date;
    NSDate *resultDate = [[NSDate alloc] initWithTimeInterval:(24 * 60 * 60 * 30 * 9 + 24 * 60 * 60 * 7) sinceDate:date];
    
    self.datePicker.hidden = YES;
    self.resultButton.hidden = YES;
    
    self.resultText.text = [NSString stringWithFormat:@"您的预产期预计为：%@", [NSString stringAnalysisWithDate:resultDate format:@"yyyy-MM-dd"]];
}

@end
